<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

/**
 * Description of LoginFormclass
 *
 * @author waterfrog
 */
class LoginForm extends sfFormSymfony
{
    public function configure()
    {

        $lang = array('zh_CN'=>'简体中文(PRC)');

        $this->setWidgets(array(
                'username' => new sfWidgetFormInputText(),
                'password' => new sfWidgetFormInputPassword(),
                'acctset' => new sfWidgetFormDoctrineChoice(array(
                    'model'=>"AcctSet",
                    "query"=>Doctrine::getTable("AcctSet")->addActiveSetQuery()
                )),
                'lang' => new sfWidgetFormChoice(array('choices'=>$lang)),
                
        ));

        //set label
        $this->widgetSchema->setLabels(array(
                'username' => '用户名:',
                'password' => '密码:',
                'acctset' => '账套名称:',
                'lang' => '语言:',
        ));

        //set validator
        $this->validatorSchema['username'] = new sfValidatorString(array('required'=>true));
        
        $this->validatorSchema['password'] = new sfValidatorString(array('required'=>true));

        $this->validatorSchema['acctset'] = new sfValidatorDoctrineChoice(array(
            "model" => "Acctset",
            "query" => Doctrine::getTable("AcctSet")->addActiveSetQuery(),
        ));

        $this->validatorSchema['lang'] = new sfValidatorChoice(array(
            'choices' => array_keys($lang),
        ));
        
        
        $this->widgetSchema->setNameFormat("login[%s]");

        
    }

}

